<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册</title>
    <link rel="stylesheet" href="../css/RegisterCss.css">
    <script src="../tool/js/jQuery.js"></script>
</head>
<body>
<div>
    <h1>欢迎注册</h1>
    账&nbsp;&nbsp;&nbsp;&nbsp;号：<input type="text" id="username" ><br>
    密&nbsp;&nbsp;&nbsp;&nbsp;码：<input type="password" id="password"><br>
    身&nbsp;&nbsp;&nbsp;&nbsp;份：<input type="text" id="identity"><br>
    <button id="register">注册</button><br>
    <button id="login">前往登录</button>
</div>
</body>
</html>
<script src="../tool/js/axios.min.js"></script>
<script>


    let reg =$("#register");

    const urlParams = new URLSearchParams(window.location.search);
    const username = urlParams.get('username');
    const password = urlParams.get('password');
    console.log('用户名:', username);
    console.log('密码:', password);
    $("#username").val(username);
    $("#password").val(password);
    reg.click(function () {
        let username = $("#username").val();
        let password = $("#password").val();
        let identity = $("#identity").val();
        console.log(username,password);
        axios.post("/user/register",{
            'username':username,
            'password':password,
            'identity':identity

        })
            .then(function (hong) {
                console.log(hong.data)

            })
    })

    let log =$("#login");
    log.click(function () {
        let username = $("#username").val();
        let password = $("#password").val();
        let identity = $("#identity").val();
        let queryString = `?username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}&identity=${encodeURIComponent(identity)}`;
        window.location.href = "logoin.html" + queryString;
    })
    // window.location.href = window.location.pathname;

</script>